// pages/collect/collect.js
Page({

  data: {
    tabs: [
      { id: 0, name: "商品收藏", isactive: true },
      { id: 1, name: "品牌收藏", isactive: false },
      { id: 2, name: "店铺收藏", isactive: false },
      { id: 3, name: "浏览足迹", isactive: false },
    ],
    collectGoodsInfo: []//缓存中商品收藏的数组
  },


  onLoad: function (options) {

  },


  onShow: function () {
    const collect = wx.getStorageSync('collect') || [];
    this.setData({
      collectGoodsInfo: collect
    })
  },
  changeTitle(index) {
    let { tabs } = this.data
    tabs.forEach((v, i) => i === index ? v.isactive = true : v.isactive = false)
    this.setData({ tabs })
  },
  indexchange(e) {
    const { index } = e.detail
    this.changeTitle(index)
  }

})